package com.example.inprinciple.openClosePrinciple;


public class OpenClosedPrinciple {
    public static void main(String[] args) {
        GraphicEditor graphicEditor = new GraphicEditor();
        graphicEditor.drawShape(new Rectangle());
        graphicEditor.drawShape(new Circle());
        graphicEditor.drawShape(new Triangle());
    }
}
class GraphicEditor{
    public void drawShape(MyShape s){
        if (s.m_type==1){
            drawRectangle(s);
        }else if (s.m_type==2){
            drawCircle(s);
        }else if (s.m_type==3){
            drawTriangle(s);
        }
    }
    private void drawCircle(MyShape s) {
        System.out.println("画圆");
    }
    private void drawRectangle(MyShape s) {
        System.out.println("画矩形");
    }
    private void drawTriangle(MyShape s) {
        System.out.println("三角形");
    }
}
class MyShape{
    int m_type;
}
class Rectangle extends MyShape{
    Rectangle(){
        super.m_type=1;
    }
}
class Circle extends MyShape{
    Circle(){
        super.m_type=2;
    }
}
class Triangle extends MyShape{
    Triangle(){
        super.m_type=3;
    }
}